package com.seecen.HJM.controller;

import com.seecen.HJM.model.dto.CommentDTO;
import com.seecen.HJM.model.dto.PlaylistDTO;
import com.seecen.HJM.model.dto.SongDto;
import com.seecen.HJM.model.entity.Comment;
import com.seecen.HJM.model.vo.PlayListVo;
import com.seecen.HJM.model.vo.SongVo;
import com.seecen.HJM.result.DataVo;
import com.seecen.HJM.result.PageResult;
import com.seecen.HJM.service.UserFavoriteService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author TOYA
 * @date 2025/10/5 16:35
 * @description: 前台歌曲喜欢
 */


@RestController
@RequestMapping("/favorite")
public class UserFavoriteController {
    @Autowired
    private UserFavoriteService userFavoriteService;

    /**
     * 获取用户收藏的歌曲列表
     *
     * @return 用户收藏的歌曲列表
     */
    @PostMapping("/getFavoriteSongs")
    public DataVo<PageResult<SongVo>> getUserFavoriteSongs(@RequestBody @Valid SongDto songDTO) {
        return userFavoriteService.getUserFavoriteSongs(songDTO);
    }

    /**
     * 收藏歌曲
     *
     * @param songId 歌曲id
     * @return 收藏结果
     */
    @PostMapping("/collectSong")
    public DataVo collectSong(@RequestParam Long songId) {
        return userFavoriteService.collectSong(songId);
    }

    /**
     * 取消收藏歌曲
     *
     * @param songId 歌曲id
     * @return 取消收藏结果
     */
    @DeleteMapping("/cancelCollectSong")
    public DataVo cancelCollectSong(@RequestParam Long songId) {
        return userFavoriteService.cancelCollectSong(songId);
    }

    /**
     * 获取用户收藏的歌单列表
     *
     * @return 用户收藏的歌单列表
     */
    @PostMapping("/getFavoritePlaylists")
    public DataVo<PageResult<PlayListVo>> getFavoritePlaylists(@RequestBody @Valid PlaylistDTO playlistDTO) {
        return userFavoriteService.getUserFavoritePlaylists(playlistDTO);
    }

    /**
     * 收藏歌单
     *
     * @param playlistId 歌单id
     * @return 收藏结果
     */
    @PostMapping("/collectPlaylist")
    public DataVo collectPlaylist(@RequestParam Long playlistId) {
        return userFavoriteService.collectPlaylist(playlistId);
    }

    /**
     * 取消收藏歌单
     *
     * @param playlistId 歌单id
     * @return 取消收藏结果
     */
    @DeleteMapping("/cancelCollectPlaylist")
    public DataVo cancelCollectPlaylist(@RequestParam Long playlistId) {
        return userFavoriteService.cancelCollectPlaylist(playlistId);
    }



}
